<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	String basepath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ request.getContextPath() + "/";
%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<style type="text/css">
*{	margin:0;
	padding:0;
}
div{
	
	box-sizing:border-box; 
	-moz-box-sizing:border-box;
	-webkit-box-sizing:border-box;
}
body{
	background: #f7f7f7;
}
.clearfix:before,.clearfix:after{ 
    content:""; 
    display:table; 
} 
.clearfix:after{clear:both;} 
.clearfix{ 
 *zoom:1;/*IE/7/6*/
}
.body_top{
	margin-bottom: 30px;
	background: #fff;
}
.body_top>div{
	width: 870px;
	height: 85px;

	margin:0 auto;
	padding-top:10px; 
}
.body_top>div>p{
	font-family:"微软雅黑";
	color: #90c624;
	font-size:40px;
	font-weight:900;
	display: inline-block;
}
.body_top>div>span{
	font-size: 14px;
	color: #8f8f8f;
	float: right;
	margin-top: 20px;
}
.body_top>div>a>img{
	float: right;
	margin: 17px 5px;
}
.body_top>div>div{
	display: inline-block;
}
.body_top>div>div>p{
	font-weight:500;
	letter-spacing: 2px;
	font-size: 18px;
	color: #8f8f8f;
}
.body_top>div>div>.last_p{
	color: #90c624;
	font-size: 12px;
	letter-spacing: 0px;
}
.body_wrap{
	width: 870px;
	margin:0 auto;
}
.body_wrap .left{
	float: left;
	height: 400px;
}
.body_wrap .left_top{
	background: #90c624;
	width: 180px;
	height: 100px;
	color: #fff;
	padding-top: 20px;
	font-size: 20px;
	font-weight:bold;
	text-align: center;
	line-height: 1;
}
.body_wrap .left_top .last_p{
	font-size: 16px;
}
.body_wrap .left_botton{
	width: 180px;
	height: 200px;
	background: #fafafa;
	font-size: 15px;
	color: #6d6d6d;
}
.body_wrap .left_botton>a{
	text-decoration: none;
	color: #000;
	display: inline-block;
	padding:10px 57px;
}
.body_wrap .left_botton>a:hover{
	background: #f0f0f0;
	border-left: 3px solid #96c720;
}
.body_wrap .right{
	width: 690px;
	float: left;
	padding-left: 30px;
}
#each_div{
	height: 400px;
}
#each_div>p{
    line-height: 20px;
    border-bottom: 1px solid #ccc;
    font-size: 13px;
    padding-left:5px;
    margin-top: 5px;
}
#each_div>p>a{
    color: #666;
    text-decoration: none;
    padding-left:10px;
}
#each_div>p>a:hover{
    color:blue;
}
#each_div>p>span{
    float: right;
    color:#ccc;
    font-size: 12px;
}
</style>
<script>
	<% if(request.getAttribute("pjax_back") != null && !request.getAttribute("pjax_back").equals("")) {%>
		<%=(String)request.getAttribute("pjax_back") %>
	<% } %>
	</script>
	<div class="body_top">
		<div>
			<p>新闻公告</p>
		    <div>
			    <p>NEWS BULLETIN</p>
			    <p class="last_p">THE BEAST PEOPLE FORMULA FOR GEART WEBSRTES</p>
		    </div>
		    <a href="index"><img src="img/btn.png"></a>
		    <span>当前位置：<span>首页</span>><span>新闻公告</span></span>
		</div>
		</div>
	<div class="body_wrap clearfix">
		<div class="left">
		    <div class="left_top">
				<p>ENTEPRENEURIAL</p>
				<p>COUNSELING</p>
				<p class="last_p">新闻公告</p>
			</div>
			<div class="left_botton">
				<c:forEach items="${requestScope.nt }" var="nt">
					<a class="pjax" href="index_news?type=${nt.nt_id }">${nt.nt_name }</a>
				</c:forEach>
				<% if(request.getAttribute("pjax_a") != null && !request.getAttribute("pjax_a").equals("")) {%> 
					<%=(String)request.getAttribute("pjax_a")%>
				<% } %>
			</div>
		</div>
		<div class="right" id="main_right">
			<div id="each_div">
                <c:forEach items="${requestScope.lists }" var="notice" varStatus="status">

                <p><a class="turn_pjax" href="index_news?page=news_info&&id=${notice.get(0).n_id}">[${notice.get(1).nt_name}]－－${notice.get(0).n_title}</a> <span>${notice.get(0).n_ctime}</span></p>
                </c:forEach> 
			</div>
	<div class="fy" title="${sum != null?sum:1 }">
			
			<span id="pre_page">上一页</span>
			<ul>
			</ul>
			<span id="next_page">下一页</span>
			
	</div>
		</div>
	</div>
<!-- <c:forEach items="${requestScope.lists }" var="notice" varStatus="status">
            <div class="news_box">
             
                <div class="news_content">
                <p>[${notice.get(1).nt_name}]－－${notice.get(0).n_ctime}</p>
                <a class="turn_pjax" href="index_news?page=news_info&&id=${notice.get(0).n_id}">${notice.get(0).n_title}</a>
                <p> ${notice.get(0).n_content}</p>
                </div>
            </div>
            </c:forEach>  -->
<script type="text/javascript">
$(document).ready(function(){
    // 拼接分页的list按钮
	 var kind=location.pathname.split("index_")[1];
	    var type=location.search.split("?")[1];
	    var sum =$("div.fy").attr("title");
        sum= sum==0?1:sum;	   
	    var connect_page=0;
	    printList(1);
      function printList(index){
        var fy_html="";
        var show = sum-index>7?8:sum-index+1;
        if(index<=connect_page){
            for(var i=8;i>0;i--){
                fy_html+="<li>"+(index-i+1)+"</li>";
            }
            $(".fy>ul").html(fy_html);
            $(".fy>ul>li").eq(7).addClass('fy_on');
        }else{
            for(var i=0;i<show;i++){
                fy_html+="<li>"+(index+i)+"</li>";
            }
            $(".fy>ul").html(fy_html);
            $(".fy>ul>li").eq(0).addClass('fy_on');
        }
        connect_page=index;
    }
	    //点击分页  分别触发ajax事件以及分页列表事件
	    $(".fy>ul").delegate('li','click',function(){
	        
	        $(this).addClass('fy_on');
	        $(this).siblings("li").attr("class","");
	        var page = $(this).html();
	        if(sum>8&&(page%7==1)&&page>7){
	            printList(Number(page));
	            }else{
	                connect_page=page;
	            }
	            connect_data(kind,page,type);
	            
	        })
	$("#pre_page").click(function(){
        var pre_page=(connect_page-1)%7;
        pre_page= pre_page==0?7:pre_page;
        $("div.fy>ul>li").eq(pre_page-1).trigger("click");
    });
    
     $("#next_page").click(function(){
        var next_page=(Number(connect_page)+1)%7;
         next_page= next_page==0?7:next_page ;
         next_page= next_page==1?8:next_page ;
        $("div.fy>ul>li").eq(next_page-1).trigger("click");
    }) 
    
	
    // 上一页  and 下一页
   
    function connect_data(kind,page,type){
        type= (type == undefined?"":"&&"+type);
        var address ="index_paging?html="+kind+type+"&&page="+page;
        getData(address,printNews)
    }
    // ajax传值取相应数据
    function getData(address,callback){
        $.ajax({
            type:"post",
            url:address,
            dataType:"json",
            success:function(data){
                callback(data);
                
            },
            error:function(e){
                console.log(e.message);
            }
        });
    }
    //回调函数渲染页面
	function printNews(data){
        console.log(data);
		var news_html="";
		$.each(data.paging,function(){
			var that=this.list;
			news_html+="<p><a class=\"turn_pjax\" href=\"index_news?page=news_info&&id="+that[0].n_id+"\">["+that[1].nt_name+"]－－"+that[0].n_title+"</a> <span>"+that[0].n_ctime+"</span></p>";
		});
		$("#each_div").html(news_html);
	}
    
})
</script>


